using UnityEngine;
using System.Collections;

public class COPIAS : MonoBehaviour
{

    // Use this for initialization
    void Start()
    {

    }

    // Update is called once per frame
    void Update()
    {

    }

    /*    private void MoveTowards()
        {
            CharacterController controller = GetComponent<CharacterController>();

            switch (movimiento)
            {
                case AIMove.Horizontal:


                    Vector3 fwd = transform.TransformDirection(Vector3.forward);
                    RaycastHit impacto;
                    if (Physics.Raycast(transform.position, fwd, out impacto))
                    {
                        //   moveDirection = impacto.point -transform.position;
                        Debug.DrawLine(transform.position, impacto.point);
                        //Debug.Log("impacto");
                    }

                    moveDirection = new Vector3(0, 0, 1);                         // direccion
                    moveDirection = transform.TransformDirection(moveDirection);
                    moveDirection *= speed;
                    moveDirection.y = 0;
                    //   moveDirection.z = 0;
                    // movimiento
                    //      moveDirection.Normalize();
                    controller.Move(moveDirection * Time.deltaTime);            // move no usa gravedad. simplemove usa gravedad estandar.

                    // llegara a su destino cuando choque con algo
                    break;
                case AIMove.Vertical:

                    break;
                case AIMove.SoloGiro:

                    break;
                case AIMove.Ruta:

                    break;
            }
        }
     * 
     * 
     * 
     * 
     * 
     * 
     * case AIMove.Horizontal:

                    Vector3 fwd = transform.TransformDirection(Vector3.left);
                    Vector3 destino = transform.position;
                    RaycastHit impacto;
                    if (Physics.Raycast(transform.position, transform.TransformDirection(Vector3.forward), out impacto))
                    {
                        destino = impacto.point;
                        Debug.DrawLine(transform.position, impacto.point);
                    }

                    transform.Translate(fwd * speed * Time.deltaTime);

                    Vector3 direction = destino - transform.position;
                    direction.y = 0;
                    if (direction.magnitude < 0.1)
                        Debug.Log("asdf");
                    // llegara a su destino cuando choque con algo
                    break;
     * 
     * 
     * 
     * 
    */

    /*
     // Funcion que mira si puedo ver al player.
    public bool CanSeeTarget()
    {

        Transform playerTF = playerControl.transform;
        Vector3 myPos = enemyControl.transform.position;
        Vector3 myVector = enemyControl.transform.forward;
        Vector3 theirPos = playerTF.transform.position;
        Vector3 theirVector = theirPos - myPos;
        float mitadAngulo = anguloVision / 2;

        //Step 2: Is the object in front of this enemy?

        float angle = Vector3.Angle(myVector, theirVector);
        bool isInFront = angle < mitadAngulo;

        //Step 3: Is there anything obscuring the object?
        Debug.DrawLine(myPos, theirPos, isInFront ? Color.green : Color.red);

        if (isInFront)
        {
            // si el rayo no choca contra la mascara, es el player
            int mask = 1 << LayerMask.NameToLayer(StringConstants.TAG_OBSTACULO);
            if (!Physics.Linecast(myPos, theirPos, mask))
            {
                Debug.Log("esta enfrente!! ");
                seeingPlayer = true;
            }
            else
            {
                Debug.Log("esta enfrente!! pero obstaculo");
                seeingPlayer = false;
            }
        }


        return seeingPlayer;
    }
      
      
     */


    /*
     // movimiento player anterior
               if (controller.isGrounded)
               {
                   moveDirection = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));
                   moveDirection = transform.TransformDirection(moveDirection);
                   moveDirection *= walkSpeed;

                   // para saltar
                   //if (Input.GetButton("Jump"))
                   //    moveDirection.y = jumpSpeed;
            

               }

               moveDirection.y -= gravity * Time.deltaTime;
               controller.Move(moveDirection * Time.deltaTime);
       
     
     
     */
}
